<extend name="Common@Layout:hui-admin" />
<block name="title"><title>Administator管理后台</title></block>
<block name="style">

</block>

<block name="main">
<div class="pd-20">
	<form action="{:u('Lessonadmin/editlesson_post')}" method="post" class="form form-horizontal validator_form close-dialog" id="form-article-add">
		 
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>校区：</label>
			<div class="formControls col-8">
			 	<span>{$district}</span>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>课堂：</label>
			<div class="formControls col-8">
			 	<span>{$class}</span>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>名称：</label>
			<div class="formControls col-4">
			 	<input name="lessonname" class="input-text"  value="{$info.lessonname}" data-rule="班级名称:required;"/>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>班级类型：</label>
			<div class="formControls col-8">
			  <span class="select-box inline">
				<select name="lessontype" class="select">
					{$classtypeoptions}
				</select>
			</span>
				<php>$info['cid']?$cid=$info['cid'] : $cid = $_GET['cid'];
				</php>
				<a class="btn btn-primary radius" onclick="parent.Hui_admin_tab(this)" _href="{:U('Classadmin/classtypelist',array('cid'=>$cid))}" data-title="分类列表"><i class="Hui-iconfont"></i> 添加分类</a>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>班级代码：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.lessoncode}" placeholder="" name="lessoncode"  data-rule="课堂代码:required;">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>上课时间：</label>
			<div class="formControls col-4">
			  	<input type="text" class="input-text" value="{$info.lessontime}" placeholder="" name="lessontime"  data-rule="上课时间:required;">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>人数：</label>
			<div class="formControls col-2">
				<input type="text" class="input-text" value="{$info.number}" placeholder="" name="number"  data-rule="人数:required;integer[+0]">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">排序值：</label>
			<div class="formControls col-2">
				<input type="text" class="input-text" value="{$info.listorder|default=0}" placeholder="" id="" name="listorder">
			</div>
		</div>
	  	<div class="row cl">
	    	<div class="col-9 col-offset-2">
	    		<if condition="$info">
	    		<input type="hidden" name="cid" value="{$info['cid']}">
	    		<else/>
	    		<input type="hidden" name="cid" value="{$cid}">
	    		</if>
	    		<input type="hidden" name="id" value="{$info['id']}">
	      		<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
	    	</div>
	  	</div>
	</form>
</div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$('.mini-time').datepicker();
	
	get_class();
	
});

$("input[name='worknum']").blur(function(){
	get_total();
});
$("input[name='price']").blur(function(){
	get_total();
});
$("input[name='materialcost']").blur(function(){
	get_total();
});

function get_total(){
	var total;
	var worknum = $("input[name='worknum']").val();//课次
	var price = $("input[name='price']").val();//单价
	var materialcost = $("input[name='materialcost']").val();//材料费
	if(worknum !=='' && price !=='' && materialcost!==''){
		total = (parseFloat(price)+parseFloat(materialcost))*parseInt(worknum);
		$("input[name='total']").val(total);
	}
}

function get_class(){
	var html = selected = '';
	var did = $("#district").val();
	var cid = $("#class").attr("data-cid");
	$.post("/Ygcl/Classadmin/get_class",{did:did},function(data){
		if(data.status){
			var obj = data.info;
			for ( var p in obj ){
				if(cid == obj[p]['id']){
					selected = 'selected';
				}else{
					selected = '';
				}
				html +='<option value="'+obj[p]['id']+'" '+selected+'>'+obj[p]['title']+'</option>';
			}
			$("#class").empty().append(html);
		}else{
			$("#class").empty();
		}
	})
}
$("#district").change(function(){
	get_class();
})
$(".classtype").click(function(){
	window.parent.classtype();
})
</script>
</block>